<include file="Common:header" />
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.all.js"> </script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="__PUBLIC__/uploadify/jquery.uploadify.min.js"></script>
<link type="text/css"  rel="stylesheet" href="__PUBLIC__/uploadify/uploadify.css">
<style type="text/css">
    .edui-default{line-height:20px;}
    div.edui-combox-body,div.edui-button-body,div-edui-splitbutton-body{overflow:hidden;height:20px}
    div.edui-box{overflow:hidden;height:22px}
    .uploadify{display:inline-block;}
    .uploadify-button{border:none;border-radius:5px;margin-top:8px;}
    table.add_tab tr td span.uploadify-button-text{color:#FFF;margin:0;}
    #art_thumb_img{max-height: 130px;max-width: 500px;margin-top: 10px;}
</style>
</head>
<body>
<!--面包屑导航 开始-->
<div class="crumb_warp">
    <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
    <i class="fa fa-home"></i> <a href="{:U(MODULE_NAME.'/Index/info')}">首页</a> &raquo; 添加文章
</div>
<!--面包屑导航 结束-->

<!--结果集标题与导航组件 开始-->
<div class="result_wrap">
    <div class="result_title">
        <h3>快捷操作</h3>
    </div>
    <div class="result_content">
        <div class="short_wrap">
            <a href="{:U(MODULE_NAME.'/Article/add')}"><i class="fa fa-plus"></i>新增文章</a>
            <a href="#"><i class="fa fa-recycle"></i>批量删除</a>
        </div>
    </div>
</div>
<!--结果集标题与导航组件 结束-->

<div class="result_wrap">
    <form action="{:U(MODULE_NAME.'/Article/add')}" method="post">
        <table class="add_tab">
            <tbody>
            <tr>
                <th width="120"><i class="require">*</i>分类：</th>
                <td>
                    <select name="cate_id">
                        <foreach name="cate" item="v">
                        <option value="{$v.cate_id}">{$v._cate_name}</option>
                        </foreach>
                    </select>
                </td>
            </tr>
            <tr>
                <th><i class="require">*</i>文章标题：</th>
                <td>
                    <input type="text" class="lg" id="art_title" name="art_title">
                    <p>标题可以写30个字</p>
                </td>
            </tr>
            <tr>
                <th>作者：</th>
                <td>
                    <input type="text" name="art_editor" value="{$Think.session.username}">

                </td>
            </tr>
            <tr>
                <th>缩略图：</th>
                <td>
                    <input type="text" size="50" name="art_thumb">
                    <input id="file_upload" name="file_upload" type="file" multiple="true">
                </td>
            </tr>
            <tr>
                <th>缩略图预览：</th>
                <td>
                    <img src="__PUBLIC__/uploadify/nopic.jpg" id="art_thumb_img"/>
                </td>
            </tr>
            <tr>
                <th>关键词：</th>
                <td><input type="text" class="lg" name="art_tag"></td>
            </tr>

            <tr>
                <th>描述：</th>
                <td>
                    <textarea name="art_description"></textarea> <p>用于SEO的description</p>
                </td>
            </tr>

            <tr>
                <th>摘要：</th>
                <!--style="resize: none; height: 100px; width: 600px; maxwidth: 600px; maxheight: 100px; overflow: auto;"-->
                <td><textarea name="art_summary" ></textarea></td>
            </tr>
            <tr>
                <th><i class="require">*</i>文章内容：</th>
                <td>
                    <script id="editor" name="art_content" id="art_content" type="text/plain" style="width:850px;height:500px;"></script>
                </td>
            </tr>
            <tr>
                <th></th>
                <td>
                    <input type="submit" id="button" value="提交">
                    <input type="button" class="back" onclick="history.go(-1)" value="返回">
                </td>
            </tr>
            </tbody>
        </table>
    </form>
</div>

<script type="text/javascript">
    var sid = '{:session_id()}';
    //实例化编辑器
    var ue = UE.getEditor('editor', {
        //serverUrl: '/server/ueditor/controller.php'
    });
    $(function() {
        $('#file_upload').uploadify({
            'debug' : false,// 是否开启浏览器调试
            'buttonText' : '缩略图上传',
            'formData'     : {'timestamp' : '<?php echo time();?>','session_id' : sid},
            'swf'      : "__PUBLIC__/uploadify/uploadify.swf",
            'uploader' : "{:U(MODULE_NAME.'/Upload/uploadify')}",
            "onUploadSuccess" : uploadPicture
            /*        'onUploadSuccess' : function(file, data, response) {
             if(response){
             $('input[name=art_thumb]').val(data);
             $('#imagefile').attr('src','__ROOT__/Uploads/thumb/'+data);
             }else{
             alert(response);
             alert(data.info);
             }
             }*/
        });

        //可以根据自己的要求来做相应处理
        function uploadPicture(file, data){
            var data = $.parseJSON(data);
            var src = '';
            if(data.status){
                $('input[name=art_thumb]').val(data.info);
                $('#art_thumb_img').attr('src','__ROOT__/Uploads/thumb/'+data.info);
            } else {
                alert(data.info);
            }
        }

        $("#button").click(function() {
            var art_title = $("#art_title").val();
            var art_content = $('textarea[name=art_content]').val();
            if(art_title == ''){
                layer.msg('文章标题不能为空！');
                $("#art_title").focus();
                return false;
            }
            if(art_content ==null ){
                layer.msg('文章内容不能为空！');
                return false;
            }
        });
    });
</script>
</body>
</html>